<template>
  <div class="score_behavior">
    <div v-if="bankData" class="behavior_body">
      <h2 class="title">本学期已累计学习行为</h2>
      <div class="tab_number">
        <div class="tab_item">
          <strong>{{bankData.termStudyBehavior}} <span>次</span></strong>
        </div>
        <div class="tab_item">
          <p style="margin-top: 5px">本月学习次数</p>
          <p>要求达到 <span>{{bankData.behaviorRequire}}</span> 次以上</p>
        </div>
      </div>
      <div class="title_h2">累计行为</div>
      <div class="tab_kc">
        <div class="tab_item">
          <strong>{{bankData.courseStudyBehavior}} <span>个</span></strong>
          <p>完成课程学习</p>
        </div>
        <div class="tab_item">
          <strong>{{bankData.onlineLessonAchieve}} <span>次</span></strong>
          <p>参与直播课</p>
        </div>
        <div class="tab_item">
          <strong>{{bankData.homeworkAchieve}} <span>个</span></strong>
          <p>完成形考任务</p>
        </div>
      </div>
      <div class="title_h2">学霸榜</div>
      <div class="ranking_body">
        <div v-if="bankData.ownRank" class="ranking_user" @click="goHomework()">
          <img src="../../../assets/img/modules/score/score_4.png" alt="">
          <div class="text_body">
            <h5>{{bankData.ownRank.studentName}}<span>{{bankData.ownRank.specialtyName}}</span></h5>
            <p>您当前排名第 <span>{{bankData.ownRank.rankNum}}</span> 位</p>
          </div>
          <div class="right_number">{{bankData.ownRank.behaviorTimes}}</div>
        </div>
        <div class="ranking_item"  v-for="(item, index) in bankData.rankList" :key="item.studentId">
          <div class="number" :data-number="index+1">{{index > 2 ? index+1: ''}}</div>
          <div class="user_data">
            <img :src="item.userPic?item.userPic:'http://m.oucgz.cn/images/default_user.png'" alt="">
            <div class="text_body">
              <h5>{{item.studentName}}</h5>
              <p>{{item.specialtyName}}</p>
            </div>
          </div>
          <div class="right_number">{{item.behaviorTimes}} 次</div>
        </div>
        <!--            <div class="bootom_line">—— 我也是有底线的哦 ——</div>-->
      </div>
      <div v-if="bankData.rankList.length === 0" class="no_work">
        <img  src="../../../assets/img/modules/score/no_homework.png" alt="">
        <p>暂无数据</p>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'score_behavior',
  components: {},
  data () {
    return {
      bankData: {
        rankList: [] // 学习情况
      }
    }
  },
  props: {},
  watch: {},
  methods: {
    /*
     *@author wf_Huang
     *@Time 2019/8/8 0008 10:22
     *@function  获取p学习情况
     *****************************************/
    getRank () {
      this.$http({
        url: `${window.SITE_CONFIG['personalListURL']}/api/courseNew/studyBehaviorRank?studentId=${this.$store.state.score.studentId}&gradeId=${this.$store.state.score.gradeId}&limitSize=10`,
        method: 'get',
        withCredentials: false
      }).then(({ data: res }) => {
        if (res.msgCode !== 200) {
          this.$toast('请求失败，请重试')
          return false
        }
        this.bankData = res.data
      }).catch(() => {})
    }
  },
  computed: {},
  created () {
  },
  mounted () {
    if (this.$route.query.studentId) {
      this.$store.state.score.studentId = this.$route.query.studentId
      localStorage.setItem('stateData', JSON.stringify(this.$store.state))
    }
    if (this.$route.query.gradeId) {
      this.$store.state.score.gradeId = this.$route.query.gradeId
      localStorage.setItem('stateData', JSON.stringify(this.$store.state))
    }
    this.getRank()
  },
  destroyed () {
  }
}
</script>
<style lang="scss" scoped>
  .score_behavior {
    .behavior_body{
      margin: 32px 32px 80px 32px;
      padding-bottom: 60px;
      .title{
        font-size: 36px;
        color: #4A4A4A;
        letter-spacing: 0;
        text-align: center;
        font-family: PingFangSC-Semibold;
        margin: 45px 0;
        text-align: center;
      }
      .tab_number{
        display: flex;
        align-content: center;
        margin: 60px 30px;
        align-items: center;
        .tab_item{
          flex: 1;
          text-align: center;
          strong{
            font-family: DINAlternate-Bold;
            font-size: 100px;
            color: #1F93FD;
            letter-spacing: 0;
            display: block;
            text-align: left;
            span{
              font-family: PingFangSC-Regular;
              font-size: 30px;
              color: #666666;
              letter-spacing: 0;
              line-height: 24px;
              font-weight: normal;
            }
          }
          p{
            font-family: PingFangSC-Regular;
            font-size: 30px;
            color: #666666;
            letter-spacing: 0;
            text-align: right;
            margin: 0;
            span{
              font-family: PingFangSC-Regular;
              font-size: 32px;
              color: #FBA34A;
              letter-spacing: 0;
              line-height: 42px;
            }
          }
        }
      }
      .title_h2{
        font-family: PingFangSC-Regular;
        font-size: 28px;
        color: #222222;
        letter-spacing: 0;
        border-left: 7px solid #1F93FD;
        padding-left: 15px;
      }
      .tab_kc{
        display: flex;
        align-content: center;
        margin: 60px 0;
        .tab_item{
          flex: 1;
          text-align: center;
          strong{
            font-size: 52px;
            color: #1F93FD;
            letter-spacing: 0;
            display: block;
            span{
              font-size: 22px;
              color: #666666;
              letter-spacing: 0;
              font-weight: normal;
            }
          }
          p{
            font-size: 22px;
            color: #666666;
            letter-spacing: 0;
            margin: 0;
          }
        }
      }
      .ranking_body{
        .ranking_user{
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin: 50px 0;
          img{
            width: 110px;
            height: 110px;
            border-radius: 100px;
          }
          .text_body{
            width: 68%;
            h5{
              font-family: PingFangSC-Medium;
              font-size: 36px;
              color: #333333;
              letter-spacing: 0;
              line-height: 28px;
              margin: 0;
              span{
                font-size: 24px;
                color: #6B6B6B;
                letter-spacing: 0;
                line-height: 28px;
                font-weight: normal;
              }
            }
            p{
              font-size: 28px;
              color: #333333;
              letter-spacing: 0;
              line-height: 28px;
              margin: 10px 0;
              span{
                color: #1F93FD;
              }
            }
          }
          .right_number{
            font-family: PingFangSC-Regular;
            font-size: 30px;
            color: #4A4A4A;
            letter-spacing: 0;
            text-align: right;
            line-height: 28px;
          }
        }
        .ranking_item{
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin: 35px 0;
          .number{
            width: 68px;
            height: 49px;
            font-size: 28px;
            color: #333333;
            display: flex;
            align-items: center;
            justify-content: center;
          }
          .number[data-number='1']{
            background: url("../../../assets/img/modules/score/score_6.png") no-repeat center;
            background-size: 100%;
          }
          .number[data-number='2']{
            background: url("../../../assets/img/modules/score/score_7.png") no-repeat center;
            background-size: 100%;
          }
          .number[data-number='3']{
            background: url("../../../assets/img/modules/score/score_8.png") no-repeat center;
            background-size: 100%;
          }
          .user_data{
            display: flex;
            width: 70%;
            justify-content: space-between;
            img{
              width: 90px;
              height: 90px;
              border-radius: 100px;
            }
            .text_body{
              width: 75%;
              h5{
                font-size: 28px;
                color: #333333;
                letter-spacing: 0;
                margin: 10px 0;
              }
              p{
                font-size: 24px;
                color: #9B9B9B;
                letter-spacing: 0;
                margin: 0;
              }
            }
          }
          .right_number{
            font-family: PingFangSC-Regular;
            font-size: 30px;
            color: #4A4A4A;
            letter-spacing: 0;
            text-align: right;
            line-height: 28px;
          }
        }
        .bootom_line{
          ont-family: PingFangSC-Regular;
          font-size: 26px;
          text-align: center;
          color: #C8C8C8;
        }
      }
    }
    .no_work{
      padding: 50px;
      text-align: center;
      img{
        display: block;
        margin: 0 auto;
        width: 400px;
      }
      p{
        font-size: 24px;
        color: #999999;
      }
    }
  }
</style>
